package com.edu.d8_generic_method;

import java.util.Arrays;

public class GenericDemo {
    /**
     * 泛型方法：可以让方法更加灵活的去接收数据
     */
    public static void main(String[] args) {
        int[] a={111,22,44,32,66,41,82};
        System.out.println(Arrays.toString(a));
        String[] b={"小明","小红","小乐"};
        show(b);
    }
    public static <T> void show(T[] a){
        if(a!=null){
            StringBuilder builder = new StringBuilder("[");
            for (int i = 0; i < a.length; i++) {
                builder.append(a).append(i==a.length-1?"":",");
            }
            System.out.println(builder.toString());
        }else{
            System.out.println(a);
        }
    }
}
